/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package casino;

import java.util.Set;

/**
 * A player that "always bet on black". 
 * 
 * @author  amaghfur
 * @since   1.0
 */
public class Passenger57 extends Player {
    
    /** outcome this player always chooses */
    private Outcome black;
    /** amount to always bet */
    private Rational betAmount = new Rational(10);
    
    /**
     * Class constructor for Passenger57 and the table he will be playing on.
     * 
     * @param tableToPlay   the table this player is playing on
     * @param startingStake money player starts with
     */
    public Passenger57(Table tableToPlay) {
        super(tableToPlay);
        black = OutcomeFactory.getOutcomeFactory().createOutcome("Black", 1);
    }
    
    /**
     * Place a fixed amount on black as a bet on the table this player is playing on.
     */
    @Override
    public void placeBets() {
        Bet blackBet = new Bet(betAmount, black);
        setStake(getStake().minus(betAmount));
        
        try {
            getTable().placeBet(blackBet);
        }
        catch (InvalidBetException e) {
            System.err.println("Caught InvalidBetException: " + e.getMessage());
        }
    }
    
    /**
     * Notifies this player that his bet specified on the argument is a winner and
     * by how much.
     * 
     * @param bet   winning bet
     */
    @Override
    public void win(Bet bet) {
        setStake(getStake().plus(bet.winAmount()));
        System.out.println(bet.toString() + " -> won " + bet.winAmount().toString());
    }
    
    /**
     * Notifies this player that his bet specified on the argument is a loser and
     * by how much.
     * 
     * @param bet   losing bet
     */
    @Override
    public void lose(Bet bet) {
        System.out.println(bet.toString() + " -> lost " + bet.loseAmount().toString());
    }
    
    /**
     * Inherited abstract method not important for this subclass.
     * 
     * @param outcomes 
     */
    @Override
    public void winners(Set<Outcome> outcomes) {
    }
    
    /**
     * No need to implement this abstract method.
     */
    @Override
    public void reset(){
    }
    
}
